﻿Imports Microsoft.VisualBasic
Imports System.Data
Imports ADOEntityLogTran
Public Class clsLogTransaction

    Dim LogTransactionEntity As LogTransactionEntities = New LogTransactionEntities
    Dim clsDatabase As clsDatabase
    Dim dsLog As DataSet

    Public Sub saveLogTransaction(ByRef UniqueID As String, ByVal UpdateBy As String, ByVal TranType As Integer, ByVal desc As String, ByVal Program As String)

        clsDatabase = New clsDatabase
        LogTransactionEntity.Connection.Open()

        If UniqueID = "&nbsp;" Then
            UniqueID = ""
        End If

        dsLog = New DataSet
        Dim sql As String = "select KYCADMIN.LOG_TRANSACTION_S.nextval from dual"
        dsLog.Tables.Add(clsDatabase.QueryDataSet(sql, "GENLOG").Tables("GENLOG").Copy)
        Dim LogSeq As Integer = dsLog.Tables("GENLOG").Rows(0)("NEXTVAL")

        Dim newLog As New LOG_TRANSACTION

        newLog.LOGTRAN = LogSeq
        newLog.LOGDATE = Now
        newLog.UNIQUEID = UniqueID
        newLog.UPDATEBY = UpdateBy
        newLog.TRANTYPE = TranType
        newLog.DESCRIPTION = desc
        newLog.PROGRAMCODE = Program

        LogTransactionEntity.AddToLOG_TRANSACTION(newLog)

        LogTransactionEntity.SaveChanges()
        LogTransactionEntity = Nothing
        clsDatabase = Nothing
        dsLog = Nothing
    End Sub

End Class
